package com.qzyh.esb.egsa.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qzyh.esb.egsa.entity.Requirement;
import com.qzyh.esb.egsa.mapper.RequirementMapper;
import com.qzyh.esb.egsa.service.IRequirementService;
import com.qzyh.esb.egsa.utils.ResultObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 * 需求信息表 服务实现类
 * </p>
 *
 * @author whq
 * @since 2023-09-18
 */
@Service
public class RequirementServiceImpl extends ServiceImpl<RequirementMapper, Requirement> implements IRequirementService {

    @Autowired
    private RequirementMapper requirementMapper;

    @Override
    public IPage<Requirement> getList(IPage<Requirement> page, String name, String num) {
        QueryWrapper<Requirement> wrapper = Wrappers.query();
        if (StringUtils.hasLength(name)){
            wrapper.like("name", name);
        }
        if (StringUtils.hasLength(num)){
            wrapper.like("num", num);
        }
        wrapper.orderByDesc("create_time");
        return requirementMapper.selectPage(page, wrapper);
    }
}
